from fastapi import Depends

from app.db.clickhouse_db import get_clickhouse_pool, ClickHouseHTTPPool
from app.models.gps_model import GpsModel


class GpsService:
    sql: str = "select  platenum, formatDateTime(uptime, '%Y-%m-%d %H:%M:%S') as uptime, longgitude, latitude, speed from lkywgps0"

    def searchClickHouse(self, gpsModel: GpsModel):
        clickHouseHTTPPool: ClickHouseHTTPPool = get_clickhouse_pool()
        # 业务逻辑处理
        print(f" {self.sql} where platenum = '{gpsModel.vehicle_no}' and uptime >= '{gpsModel.start_time}' and uptime<='{gpsModel.end_time}' order by uptime ")
        result = clickHouseHTTPPool.execute(
            f" {self.sql} where platenum = '{gpsModel.vehicle_no}' and uptime >= '{gpsModel.start_time}' and uptime<='{gpsModel.end_time}' order by uptime ")
        return result


gps_service = GpsService()
